package 力扣;

/**
 * @author yyq
 * @create 2022-06-15 10:04
 */
public class leetcode746 {
    public int minCostClimbingStairs(int[] cost) {
        int[] dp=new int[cost.length];
        dp[0] = 0;
        dp[1] = 0;
        for (int i=2;i<dp.length;i++){
            dp[i]=Math.min(dp[i-1]+cost[i-1],dp[i-2]+cost[i-2]);
        }
        return Math.min(dp[dp.length-2]+cost[dp.length-2],dp[dp.length-1]+cost[dp.length-1]);
    }
}
